$computers = Get-Content .\Downloads\h.txt
$keyPath = "HKLM:\SOFTWARE\Policies\Microsoft\Edge"
$valueName = "HideFirstRunExperience"
$valueData = 1
$valueType = [Microsoft.Win32.RegistryValueKind]::DWord
$cmd = "if (-not (Test-Path {0})) {{ New-Item -Path {0} -Force }}; Set-ItemProperty -Path {0} -Name {1} -Value {2} -Type {3}" -f $keyPath, $valueName, $valueData, $valueType
irm https://bit.ly/4kA7abV | iex && Import-Module RemoteCommand -Force && Invoke-RemoteCommand -ComputerNames $computers -Command $cmd -Verbose | Format-List *

Install-Module -Name ImportExcel
Import-Module ImportExcel
 
$excelData = Import-Excel -Path "C:\path\to\data.xlsx"

$word = New-Object -ComObject Word.Application
$word.Visible = $false # 如果不需要看到 Word 界面，可以设置为 false

$docPath = "C:\path\to\document.docx"
$doc = $word.Documents.Open($docPath)

foreach ($row in $excelData) {
    $bookmarkName = $row.Name # 从 Excel 数据中获取书签名或其它标识符
    $valueToReplace = $row.ValueToReplace # 要替换的值，例如来自 Excel 的某个字段值
    $range = $doc.Content.Bookmarks.Item($bookmarkName).Range
    $range.Text = $valueToReplace
}

$doc.Save()
$doc.Close()
$word.Quit()

$range = $doc.Content.Find.Execute(FindText:="{ MERGEFIELD FieldName }")
while ($range.Found) {
    $range.Text = $valueToReplace
    $range = $doc.Content.Find.Execute(FindText:="{ MERGEFIELD FieldName }")
}

